Repository navigation
Fix/project update issues - #122
pancysingla-creator wants to merge 4 commits into
Conversation
Projects whose labels are null (or omitted by the API) crashed the Project Info confirm dialog on Submit with "Cannot read properties of undefined (reading 'map')", so no PUT request was sent. Default both the original and the edited labels to an empty list before mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a webhook replies with a 4xx, the project update now fails with a 400 that carries the webhook's own error message plus the project's team and stream, instead of a 500 with the raw response. For example, a team that is not registered in Warden now reads: webhook_1 rejected the request (status 404): team not found (project team "ds_identity", stream "ds_identity"). Check that the team and stream are valid, and change them on the Project Info page if needed - Webhook client: a 4xx reply becomes an InvalidArgumentError with the webhook's message, and is no longer retried. 5xx replies are unchanged. - UpdateProject: add the project's team and stream to that error, and log the correct event name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anantadwi13
left a comment
There was a problem hiding this comment.
btw i have some concerns below. wdyt?
|
|
||
| "github.com/avast/retry-go/v4" | ||
| "github.com/caraml-dev/mlp/api/log" | ||
| apperror "github.com/caraml-dev/mlp/api/pkg/errors" |
There was a problem hiding this comment.
i prefer this package shouldn't import another package, and let's use its internal error instead in errors.go
There was a problem hiding this comment.
Alright, sure!
| "and change them on the Project Info page if needed", | ||
| err, project.Team, project.Stream, | ||
| ) | ||
| } |
There was a problem hiding this comment.
btw, somehow i prefer we are not changing this logic. it should be still returning 500 error instead of 4xx (apperror.NewInvalidArgumentErrorf), because it is the server internal communication with webhook server, and it can be used to call any endpoints (not just related to team & stream management). that means asking the user to check team & stream are valid might lead to misinformation
also, the user is expected not to know this kind of issue. i prefer the error message tells the user to contact the platform owner, and the platform owner add some FAQ docs to help user tackle this kind of issue.
nice to have: adding request id or any reference id to the error message to make debugging process easier
There was a problem hiding this comment.
I had a few clarifications regarding this:
-
QA report mentioned we want the user to see 404 instead of 500, and we should wrap a 4xx response from a webhook as apperror.InvalidArgumentError or apperror.NotFoundError, but as you mentioned above should it be kept 500? Should we append "Please contact the platform owner" directly in webhooks/errors.go (so the API response carries it), or handle that phrasing on the UI side? Is there any specific support channel we should link to in that case?
-
For request id or any reference id part, does mlp already attach a request ID or headers or should we generate a UUID per webhook call and append it to the error message?
There was a problem hiding this comment.
- ok, appending directly to webhook error should work as well
- afaik, we dont return any req id. since changing all endpoints is not a good idea, yes, i believe we can generate uuid per webhook call and append it to the error message
There was a problem hiding this comment.
maybe this one is a good place to append the message
mlp/api/pkg/webhooks/errors.go
Line 12 in 52bf4ac
There was a problem hiding this comment.
Got it, I'll make the changes!
There was a problem hiding this comment.
I have made the fixes mentioned, please let me know if there is any issue!
| if resp.StatusCode >= http.StatusBadRequest && resp.StatusCode < http.StatusInternalServerError { | ||
| return retry.Unrecoverable(apperror.NewInvalidArgumentErrorf( | ||
| "%s rejected the request (status %d): %s", g.Name, resp.StatusCode, webhookErrorMessage(content), | ||
| )) | ||
| } |
There was a problem hiding this comment.
regarding my comment here https://github.com/caraml-dev/mlp/pull/122/changes#r4623239246
this seems like not necessary
…e platform owner Webhooks can call any endpoint, so a webhook failure is a server-side problem, not invalid user input. Revert the 4xx-to-400 mapping and keep returning 500, with a message that tells the user to contact the platform owner. - Webhook client: remove the 4xx special case and the apperror import. - WebhookError: append "Please contact the platform owner" to the message. - UpdateProject: remove the team/stream hint; keep the corrected log event name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MLP does not return a request id, so each WebhookError now gets its own UUID. It is part of the error message, so the user can quote it to the platform owner, who can find the matching log line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Description
Fixes two errors when updating a project from the console.
1. Project Info: Submit crashes when the project has no labels
If a project's
labelsisnull, the API leaves the field out and the confirm dialog crashes onlabels.map. The page shows "Something Went Wrong" and no PUT is sent.Fix: default
labelsto an empty list inUpdateProjectInfoModal.2. User Roles / Project Info: unclear 500 when a webhook rejects the update
When the
OnProjectUpdatedwebhook replies with a 4xx (e.g. 404team not found), the API returned a 500 with the raw webhook response, which doesn't tell the user what to fix.Fix: webhook failures can come from any endpoint the webhook calls, not just team/stream checks, so the response stays a 500. Instead, the message now tells the user to contact the platform owner and includes a reference ID, so the platform owner can find the matching log line for the full error.